require.config({
	paths: {
		jquery:		'jquery-2.1.4.min',
		bootstrap:	'bootstrap.min',
		supermap:	'supermap2d',
		app:		'app2d',
		ztreeCore:  'jquery.ztree.core',
		ztreeExcheck: 'jquery.ztree.excheck'
	},
	shim: {
		ztreeExcheck:{
			deps : ['ztreeCore'],
			exports: 'ztreeExcheck'
		},
		ztreeCore:{
			deps : ['jquery'],
			exports: 'ztreeCore'
		},
		bootstrap : {
			deps : ['jquery'],
			exports: 'bootstrap'
		},
		layui : {
            deps : ['jquery'],
            exports: 'layui'
        }
	}
});
require(["jquery","supermap","app","bootstrap","layui","ztreeCore","ztreeExcheck"],function($,SM,APP,BS,layui,ztree_core,ze){
	APP.autodivheight();
    window.onresize = APP.autodivheight; //浏览器窗口发生变化时同时变化DIV高度

	//加载layui
	layui.use(['element','form'], function(){
		var element = layui.element;
		var form = layui.form;
		//当条件查询select发生改变
		form.on('select(selectValue)', function(data){
			$('#sqlselectText1').val(data.value);
	    }); 
	});

	//加载地图
	SM.onload(APP);
	
	//左侧-查询
	$('#tab-content').on('click','#infoHot',function(){APP.infoHot($(this).attr('name'))});//信息热点
	$('#tab-content').on('click','#sqlselect', APP.sqlselect); //条件查询
	
	//右侧-工具
	$('#toolbar').on('click','#distance',APP.distance);//测距
	$('#toolbar').on('click','#area',APP.area);//侧面
	$('#toolbar').on('click','#clear',APP.clear);//清除
	$('#toolbar').on('click','.plotting',function(){APP.plotting($(this).attr('role'))});//标会
	$('#toolbar').on('click','#swipe',APP.windowCurtains);
	$('#toolbar').on('click','#printMap',function(){APP.printMap('mapDiv')});//地图打印
	$('#toolbar').on('click','#cutMap',APP.cutMap);//地图截图
	$('#toolbar').on('click','#vectorInfo',APP.vectorInfo);//矢量信息
	//$('#toolbar').on('click','#layerBtn',function(){APP.getLayer('#rightLayer #getLayerTree')});//图层
	$('#toolbar').on('click','#layerBtn',APP.layerTree);//图层

	//右侧-工具
	$('#toolbar').on('click','#educeInfo',APP.educeInfo);//地图属性字段导出
	$('#exportExcel').on('click',APP.testalert);//table导出
	//左侧-工具
	$('#tab-content').on('click','#geometric',APP.geometric);//框选统计
	$('#tab-content').on('click','#polygonalSelection',APP.polygonalSelection);//多边形统计
	$('#tab-content').on('click','#landUsed',APP.landUsed);//土地利用
	$('#tab-content').on('click','.landUsedRank',function(){ APP.landUsedRank($(this).attr('role')) });//数值类专题
	$('#tab-content').on('click','#labelTheme',APP.labelTheme);//标签专题
	$('#tab-content').on('click','#multipleChoice',APP.multipleChoice);//多选统计
	$('#tab-content').on('click','#bufferAnalyse',APP.bufferAnalyse);//缓冲区分析  
	$('#tab-content').on('click','#surfaceAnalysis',APP.surfaceAnalysis);//表面分析
	$('#tab-content').on('click','#pointDensity',APP.dotDensity);//点密度	
	$('#tab-content').on('click','#reverseDistance',APP.reverseDistance);//反距离 
	$('#tab-content').on('click','#kelvjin',APP.kelvjin);//克吕金
	$('#tab-content').on('click','#discretePoints',APP.discretePoints);//离散点
	
	//图层相关
	$('#tab-content').on('click','#getLayer',function(){ APP.getLayer('#'+$(this).next().attr('id')) });//图层开关	
	$('#tab-content').on('click','#baiduMap', function(){ APP.baiduMap('#'+$(this).attr('id'))});//百度地图
	$('#tab-content').on('click','#tiandiMap', function(){APP.tiandiMap('#'+$(this).attr('id'))});//天地图
	//默认打开
	$('#getLayer').prop("checked", true);
	$('#getLayer').prop("checked", "checked");
	APP.getLayer('#getLayerTree');
	//右侧图层
	$('#rightLayer').on('click','#baiduMap', function(){ APP.baiduMap('#rightLayer #baiduMap')});
	$('#rightLayer').on('click','#tiandiMap', function(){ APP.tiandiMap('#rightLayer #tiandiMap')});
	//二维图层
    // $(".tw-layer").on('click', 'input', function() {
    //     var selected = $(this).is(':checked');
    //        if(selected){
    //         $(this).parent().find('.twLayer-div').addClass('layer-display');
    //       }else {
    //         $(this).parent().find('.twLayer-div').removeClass('layer-display');
    //       }
	// });

   //切换县区
    function locationAddress(id, callback) {
		document.getElementById(id).addEventListener('click', callback);
    } 
    //老城片区
	locationAddress('lcpq', function() {
		view.animate({
		center: [451674.9629118700, 4016592.3234394998],
		duration: 2000,
		zoom:16
		});
	});
	locationAddress('sdpq', function() {
		view.animate({
		center: [450011.9039928900, 4016833.3919429001],
		duration: 2000,
		zoom:16
		});
	});
	locationAddress('dbcyxcpq', function() {
		view.animate({
		center: [449956.8855945800, 4018436.7852651998],
		duration: 2000,
		zoom:16
		});
	});
	locationAddress('jszt', function() {
		view.animate({
		center: [449119.8199631000, 4016621.1781207998],
		duration: 2000,
		zoom:16
		});
	});
	locationAddress('gyyhxpq', function() {
		view.animate({
		center: [448542.1267808100, 4016078.3331682999],
		duration: 2000,
		zoom:16
		});
	});
	locationAddress('ycpq', function() {
		view.animate({
		center: [452625.2779127800, 4015697.1342656999],
		duration: 2000,
		zoom:16
		});
	});

	locationAddress('smszt', function() {
		view.animate({
		center: [447862.2565730700, 4012159.4266156000],
		duration: 2000,
		zoom:16
		});
	});

	locationAddress('sgzt', function() {
		view.animate({
		center: [450962.9363065800, 4011216.2540731002],
		duration: 2000,
		zoom:16
		});
	});
		
	
});